#include"main.hpp"

void adminedit()
{
	student stu[MAX];
	FILE *stuin;
	if((stuin = fopen ("stugrd.txt", "rb"))==NULL)
    {
        printf("出现错误，代码：FILEERROR");
    }
    fread(stu,sizeof(struct student),MAX,stuin);
    fclose(stuin);
    bool cire=true;int a,i;char sure;
    printf("请输入学生内部编号：\n");
    scanf("%d",i);
    printgrd(stu[i]);
    system("pause");
    system("cls");
    while(cire)
    {
		printf("请输入您想要修改的项：\n");
        printf("1.姓名\n");
        printf("2.ID\n");
        printf("3.成绩\n");
        printf("0.退出\n");
        scanf("%d",a);
        switch(a)
        {
    	    case 1:printf("请输入修改后项：\n");
    	           scanf("%s",stu[i].nm);
                   break;
		    case 2:printf("请输入修改后项：\n");
			       scanf("%s",stu[i].id);
				   break;
			case 3:grdedit(&stu[i]);
			       break;
			case 0:cire=false;
			       break;
	    }		
	}
	FILE *stuout;
	if((stuout = fopen ("stugrd.txt", "rb"))==NULL)
    {
        printf("出现错误，代码：FILEERROR");
    }
    fwrite(stu,sizeof(struct student),MAX,stuout);
    fclose(stuout);
}
